// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	2/17/2015 7:42:23 PM				
// -----------------------------

#ifndef _StateManager_h
#define _StateManager_h

#include "Common.h"
#include "CommandHandler.h"

namespace Flow
{

	class BaseState;
	class SpriteBatch;

	struct StateCommand
	{
		string					Name;
		StateCommandType::Enum	Type;

		StateCommand(const string& name, StateCommandType::Enum type)
		{
			Name = name;
			Type = type;
		}
	};

	class StateManager : public CommandHandler<StateCommand>
	{
	public:

		StateManager();
		~StateManager();

		void		Update(Float deltaTime);
		void		Draw(SpriteBatch* lpSpriteBatch);

		void		AddState(BaseState* lpState);
		void		RemoveState(const string& name, Bool bDestroyState = true);

		void		PushState(const string& name);
		void		SwapState(const string& name);
		void		PopState(const string& name, StateCommandType::Enum popType);

		BaseState*	GetState(const string& name) const;

		Bool		HasState(const string& name) const;
		Bool		HasState(BaseState* lpState) const;

		Bool		IsStateOnStack(const string& name) const;
		Bool		IsStateOnStack(BaseState* lpState) const;

	private:

		virtual void	ProcessSingleCommand(StateCommand* lpCommand);

		map<string, BaseState*>	m_States;
		vector<BaseState*>		m_StateStack;

		StateManager(const StateManager& refStateManager);
		StateManager& operator=(const StateManager& refStateManager);
	};

}

#endif